<template>
	<view>
<map class="kjhjdertt" id="navi_map" longitude="113.908997" latitude="22.550611" scale="12" :markers="markers"
		 :polyline="polyline"></map>

		33333
	</view>
</template>
<script>
	import amapFile from "@/common/amap-wx.js"
	export default {
		data() {
			return {
				latitude: 22.555367,
				longitude: 113.887367,
				scale: 13,
				polyline: [],
				markers: [{
					latitude: 22.550611,
					longitude: 113.908997,
					iconPath: '../../static/img/xce.png'
				}]
			}
		},
		components: {},
		methods: {},
		onLoad() {
			var that = this;
			var myAmapFun = new amapFile.AMapWX({
				key: '4c9b557f99dc1b8f039306f3648ba4b2'
			});
			myAmapFun.getDrivingRoute({
				origin: '113.908997,22.550611',
				destination: '113.903503,22.483375',
				success: function(data) {
console.log(data)
console.log(6666)
					var points = [];
					if (data.paths && data.paths[0] && data.paths[0].steps) {
						var steps = data.paths[0].steps;
						for (var i = 0; i < steps.length; i++) {
							var poLen = steps[i].polyline.split(';');
							for (var j = 0; j < poLen.length; j++) {
								points.push({
									longitude: parseFloat(poLen[j].split(',')[0]),
									latitude: parseFloat(poLen[j].split(',')[1])
								})
							}
						}
					}
					that.polyline= [{ 
							points: points,
							color: "#0091ff",
							width: 6
						}]
					if (data.paths[0] && data.paths[0].distance) {
						that.distance=data.paths[0].distance + '米'
					}
					if (data.paths[0] && data.paths[0].duration) {
						that.cost= parseInt(data.paths[0].duration / 60) + '分钟'
					}

				},
				fail: function(info) {

				}
			})
		},
		mounted() {}
	}
</script>
<style scoped>
	.kjhjdertt {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
	}
</style>
